package com.saclub.app.utils;

import java.io.File;

import android.widget.ImageView;

import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.offroader.img.EasyImageLoader;
import com.offroader.img.EasyImageLoader.DisplayType;
import com.saclub.app.R;
import com.saclub.app.common.AppConfig;

/**
 * 图片异步加载
 * 
 * @author li.li
 *
 */
public class ImageUtils {

	public static void load(int defResId, ImageView iv, String imageUrl) {
		String imgSavePath = AppConfig.ROOT_CACHE_PATH + File.separator + AppConfig.APP_CACHE_NAME + File.separator + AppConfig.IMAGE_CACHE_PATH;
		EasyImageLoader.getInstance(imgSavePath).show(imageUrl, iv, defResId, DisplayType.def);
	}

	public static void load(ImageView iv, String imageUrl) {
		String imgSavePath = AppConfig.ROOT_CACHE_PATH + File.separator + AppConfig.APP_CACHE_NAME + File.separator + AppConfig.IMAGE_CACHE_PATH;
		EasyImageLoader.getInstance(imgSavePath).show(imageUrl, iv, R.drawable.def, DisplayType.def);
	}
	
	public static void load(ImageView iv, String imageUrl, ImageLoadingListener loadListener) {
		String imgSavePath = AppConfig.ROOT_CACHE_PATH + File.separator + AppConfig.APP_CACHE_NAME + File.separator + AppConfig.IMAGE_CACHE_PATH;
		EasyImageLoader.getInstance(imgSavePath).show(imageUrl, iv, R.drawable.def, DisplayType.def, loadListener);
	}

	public static void load(ImageView iv, String imageUrl, DisplayType disPlayType) {
		String imgSavePath = AppConfig.ROOT_CACHE_PATH + File.separator + AppConfig.APP_CACHE_NAME + File.separator + AppConfig.IMAGE_CACHE_PATH;
		EasyImageLoader.getInstance(imgSavePath).show(imageUrl, iv, R.drawable.def, disPlayType);
	}

}
